package com.credit.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.credit.entity.CreditGrabOrder;

public interface CreditGrabOrderDao extends PagingAndSortingRepository<CreditGrabOrder, Long>, JpaSpecificationExecutor<CreditGrabOrder>{

	@Query("from CreditGrabOrder grabOrder where grabOrder.managerId = ?1 and grabOrder.loanId = ?2")
	CreditGrabOrder findByUserIdAndLoanId(Long userId, long loanId);

	@Query("from CreditGrabOrder grabOrder where grabOrder.managerId = ?1 and grabOrder.loanId = ?2 and grabOrder.processFlag=?3")
	CreditGrabOrder findByManagerIdAndLoanId(Long managerId, long loanId, Integer processFlag);

	@Query("from CreditGrabOrder grabOrder where grabOrder.managerId = ?1 and grabOrder.loanId = ?2 order by updateTime desc")
	List<CreditGrabOrder> findByManagerIdAndLoanId(Long id, Long loanId);


}
